<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>


  <script>

    let arr1 = [1, 3, 4, 5, 6, 7, 7, 7]

    function getNum(arr, bln) {
      let sum = 0
      let average = 0
      // if (bln === true && undefined) {
      //   for(let i = 0;i < arr.length;i++) {
      //   sum += arr[i]
      //   return sum
      // }

      // if(bln === false) {
      //   for(let i = 0;i < arr.length;i++) {
      //   sum += arr[i]
      //   average = sum / arr.length
      //   return avrage
      // }
      for (let i = 0; i < arr.length; i++) {
        sum += arr[i]
        average = sum / arr.length

      }
      if (bln === true || 'undefined') return sum
      if (bln === false) return average 

    }
    console.log(getNum(arr1));
    console.log(getNum(arr1, false));


    // function fn(a) { 
    //   return a
    // }

    // console.log(typeof fn());

  </script>
</body>

</html>